<template>
    <div class="content-box">
        <!--工具条-->
        <el-col class="toolbar">
            <el-col :span="12">
                <h2>报表设置</h2>
            </el-col>
            <el-col :span="12">
                <el-form :inline="true">
                    <el-form-item>
                        <label for="file" class="label-file">导入</label>
                        <input name="file" id="file" type="file" accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" @change="update" />
                    </el-form-item>
                </el-form>
            </el-col>
        </el-col>
    </div>
</template>
<script>
import axios from '../../util/axios';
export default {
    name: 'ReportSet',
    data() {
        return {

        }
    },
    methods: {
        update(e) {
            let file = e.target.files[0];
            let param = new FormData(); //创建form对象
            param.append('file', file, file.name);//通过append向form对象添加数据
            param.append('chunk', '0');//添加form表单中其他数据
            console.log(param.get('file')); //FormData私有类对象，访问不到，可以通过get判断值是否传进去
            let config = {
                headers: { 'Content-Type': 'multipart/form-data' }
            };  //添加请求头
            axios.post('importReportSet', param, config)
                .then(response => {
                    console.log(response.data);
                })
        },
    },
    mounted() {

    }
}
</script>

<style scoped lang="scss">
@import '../../common/css/index.css';
</style>